<template>
  <view class="container">
    <view class="record-list">
      <view class="record-item" v-for="(item, index) in recordList" :key="index">
        <view class="record-item__tail"></view>
        <view class="record-item__icon">
        </view>
        <view class="record-item__content">
          <view class="header">
            <view class="record-title">
              <dict-tag :options="dict.type.user_display_type" :value="item.userDisplayType"/>
            </view>
            <view class="record-time">{{ item.createTime }}</view>
          </view>
          <view class="record-desc">{{ followRecordDesc(item.userDisplayType) }}</view>
        </view>
      </view>
      <view class="record-item" v-if="recordList.length === 0">
        <view class="record-item__tail"></view>
        <view class="record-item__icon">
        </view>
        <view class="record-item__content">
          <view class="header">
            <view class="record-title">
              暂无记录
            </view>
          </view>
          <view class="record-desc">暂无记录</view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import {followRecordList} from '@/api/manager/workOrder'
import dict from "@/common/dict";

export default {
  name: 'FollowUpRecord',
  dicts: ["user_display_type"],
  data() {
    return {
      // 订单ID
      workOrderId: '',
      recordList: [],
    };
  },
  computed: {
    followRecordDesc() {
      return (value) => {
        let obj = this.dict.type.user_display_type.find(item => item.value == value)
        return obj && obj.raw.remark ? obj.raw.remark : ''
      }
    }
  },
  onLoad(options) {
    const workOrderId = options.workOrderId
    if (workOrderId) {
      this.workOrderId = workOrderId
      this.getRecordList()
    }
  },
  methods: {
    async getRecordList() {
      let params = {
        workOrderId: this.workOrderId
      }
      const res = await followRecordList(params)
      if (res.code === 200) {
        this.recordList = res.data
      }
    }
  }
}
</script>

<style lang="scss">
.container {
  padding: 20px;
  background-color: #fff;

  .record-list {
    margin-top: 20px;
    padding: 10px;

    .record-item {
      margin-bottom: 10px;
      position: relative;
      display: flex;
      padding: 20px;

      &:first-child {
        .record-title {
          color: #4A96F9;
        }
      }

      &:last-child {
        .record-item__tail {
          display: none;
        }
      }

      .record-item__tail {
        position: absolute;
        left: 0;
        height: 100%;
        border-left: 4rpx solid #4A96F9;
        transform: translateX(-50%);
      }

      .record-item__icon {
        width: 20rpx;
        height: 20rpx;
        border-radius: 50%;
        background-color: #4A96F9;
        position: absolute;
        top: 0;
        left: 0;
        transform: translate(-50%, 100%);
        transform: translate(-50%, 100%);
      }

      .record-item__content {
        width: 100%;
      }

      .header {
        display: flex;
        justify-content: space-between;
        align-items: center;

        .record-title {
          font-size: 30rpx;
        }

        .record-time {
          font-size: 28rpx;
          color: #999;
        }
      }

      .record-desc {
        font-size: 14px;
        color: #666;
        line-height: 1.5;
      }
    }
  }
}
</style>
